<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/messages.jsp"%>
<%@ include file="/commons/commonEdit.jsp" %>
<%@ include file="/commons/validation.jsp" %>
<%@ include file="/commons/dateTime.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>${key.charge_recordedAccount_title}</title>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/tags/unitedselect/UnitedSelect.js"></script>
<script>
var selectId = null;
var closeFlag = null;
var houseId = null;
var houseNum = null;
var customerName = null;
function choiceHouse(){
	var url = "${ctx}/charge_cashieringAction.do?method=choosePropertyHouse&houseId=${houseId}";
	top.windowOpen(url, "choiceHouse", "", 220, 500);
}
function setHouseInfo(houseId,customerName){
		document.getElementById("houseId").value = houseId;
		document.getElementById('ownerName').innerText = customerName;
}
function onSelect(thiz,flag)
{
	if(flag == -1){
		selectId = thiz.options[thiz.selectedIndex].value;
		var url ="${ctx}/charge_cashieringAction.do?method=unitedSelect&houseId=${houseId}&selectId="+selectId+"&targetId=chargeStdId";
		onChangeSelect(url,selectId,'chargeStdId');
	}
	if(flag == -2)
	{
		temphouseId = thiz.options[thiz.selectedIndex].value;
		var url ="${ctx}/charge_cashieringAction.do?method=unitedSelect&houseId="+temphouseId+"&selectId="+temphouseId+"&targetId=chargeItemId";
		onChangeSelect(url,"temp",'chargeItemId');
	}
}
function onRadioSelect(thiz,houseId){
	selectId = thiz.id;
	var url ="${ctx}/charge_cashieringAction.do?method=unitedSelect&houseId="+houseId+"&selectId="+selectId+"&targetId=chargeStdId";
	onChangeSelect(url,selectId,'chargeItemId');
}
function setCloseFlag(flag){
	closeFlag = flag;
}
function closeFrm(response){
	if('true' == response.responseText){
    	var obj = findFrame("connTabPanel");
	    windowClose();
	    obj.refresh();
	    if(!closeFlag){ //点击的保存按钮
        	windowClose();
		}
		else {  //点击的保存并新增
       	 location.reload();
		}
    }
    else
    	ajaxSubmitException(response.responseText);

}
function ajaxSubmit(formId){
		var isTrue=$(formId).fireEvent("onSubmit");
	    if(isTrue){
         var url = document.getElementById(formId).action;
         var param = Form.serialize(formId);
         new Ajax.Request(url,{method: 'post',parameters :param ,onComplete : closeFrm});
		}
}
function setSelectedHouseInfo(houseId,houseNum,periodId,endDate,firstPayDate,lastPayDate){
	   var url = "${ctx}/customer_customerAction.do?method=queryCustomerHouse";
	   var str = "houseNumber="+houseNum;
	   document.getElementById('periodId').value = periodId;
	    $('endDate').value = endDate;
	    document.getElementById('firstPayDate').innerText=firstPayDate;
	    document.getElementById('lastPayDate').innerText=lastPayDate;
		$('temp').value=houseId;
		$('temp').fireEvent("onchange");
	   new Ajax.Request(url,{method: 'post', parameters: str, onComplete: setCustomerName});
}
function setCustomerName(_response){
		var obj=eval('(' + _response.responseText + ')');
		customerName = typeof(obj.ownerName) == 'undefined'? "" : obj.ownerName;
		setHouseInfo(obj.houseId,customerName);
		$('temp').fireEvent("on")
}
function initPrice(thiz){
	var svalue = thiz.options[thiz.selectedIndex].value;
	if(svalue!=""){
		var url ="${ctx}/charge_cashieringAction.do?method=getChargeStandardPrice&chargeStandardId="+svalue;
		new Ajax.Request(url,{method:'post',onComplete:setPrice});
	}
}
function setPrice(_response){
	var obj=eval('(' + _response.responseText + ')');
	if(obj != "0"){
		$('debit').value = _response.responseText;
	}
}
</script>
</head>

<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="121"><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle"><span class="window_head_intext">${key.charge_recordedAccount_title}</span></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td class="content"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="aux_outtable_color">
        <form name="transForm" method="post" action="${ctx}/charge_cashieringAction.do?method=addRecordedAccount" class="required-validate">
         <input type="hidden" name="periodId" value="${periodId}">
         <input type="hidden" name="endDate" value="${endDate}">
         <input type="hidden" name="accountHouseId" value="${accountHouseId}">
         <input type="hidden" name="chargeSelect" value="${chargeSelect}">
         <table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
          <tr>
            <td class="aux_intable_td1">${key.charge_recordedAccount_houseNumber}：</td>
            <c:if test="${isVirtual == '1'}">
             <td class="aux_intable_require">
           </c:if>
            <c:if test="${isVirtual == '0'}">
             <td class="aux_intable_td2">
           </c:if>
           <table border="0" cellspacing="0" cellpadding="0">
             <c:if test="${isVirtual == '0'}">
             <tr>
               <td >${houseNumber}<input type="hidden" name="houseId" value="${houseId}"></td>
               <td width="4">&nbsp;</td>
               <td >&nbsp;</td>
             </tr>
             </c:if>
             <c:if test="${isVirtual == '1'}">
             <tr>
               <td >
					<input type="hidden" name="houseId" value="">
					<select name="temp" onchange="onSelect(this,-2)" style="display:none">
					<option value="">请选择</option>
						<c:forEach items="${houseList}" var="house" varStatus="status">
		              		<option  value="${house.keyword}">${house.houseNumber}</option>
		           		</c:forEach>
					</select>
					<c:forEach items="${houseList}" var="house" varStatus="status">
		              <input type="radio" name="house" value="${house.houseNumber}" class="validate-one-required" onclick="setSelectedHouseInfo('${house.keyword}','${house.houseNumber}','${house.periodId}','${house.modifierDate}','${house.disUnitDate}','${house.sysdate}');onSelect(this,'${house.keyword}')" afterInsert="bdAfter">
		              ${house.houseNumber} &nbsp;&nbsp;&nbsp;
		            </c:forEach>
               		<span id="bdAfter"></span>
               </td>
               <td width="4">&nbsp;</td>
               <td >&nbsp;</td>
             </tr>
             </c:if>
           </table></td>
            </tr>
          <tr>
            <td class="aux_intable_td1">${key.charge_recordedAccount_ownerName}：</td>
            <c:if test="${isVirtual == '1'}">
            <td class="aux_intable_td2"><div id="ownerName"></div></td>
            </c:if>
             <c:if test="${isVirtual == '0'}">
             <td  class="aux_intable_td2">${participantName}</td>
             </c:if>
            </tr>

          <tr>
            <td class="aux_intable_td1"><span id="roomnum">${key.charge_recordedAccount_chargeItem}：</span></td>
            <td class="aux_intable_require">
					<pms:unitedSelect id="chargeItemId"
					    style="width:110px;"
						name="chargeItemId"
						actionName=""
						targetId="chargeStandard"
						dataList="${chargeItemList}"
						optionLabel="itemName"
						optionValue="keyword"
						onChange="onSelect(this,-1)"
						className="select-one-required"
						selectText="${key.select}">
              		</pms:unitedSelect>
            </td>
          </tr>
          <tr>
            <td class="aux_intable_td1">${key.charge_recordedAccount_chargeStandard}：</td>
            <td class="aux_intable_require">
            		<pms:unitedSelect
						id="chargeStdId"
						style="width:110px;"
						name="chargeStdId"
						className="select-one-required"
						onChange="initPrice(this);"
						selectText="${key.select}">
					</pms:unitedSelect>

            </td>
          </tr>
          <tr>
            <td class="aux_intable_td1">${key.charge_recordedAccount_debit}：</td>
            <td class="aux_intable_require"><table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td ><input name="debit"  type="text" class="required float-zero-right integer-decimal-range-18-2" style="text-align:right" value="" size="16"  afterInsert="debitTip" maxlength="16"></td>
                <td width="4">&nbsp;</td>
                <td >${key.yuan}<span id="debitTip"></span></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td valign="top" class="aux_intable_td1">${key.charge_recordedAccount_remark}：</td>
            <td align="left" class="aux_intable_td2">
              <textarea name="remark" cols="20" rows="4" class="max-length-500"></textarea>
            </td>
          </tr>
          <tr>
            <td class="aux_intable_td1">${key.charge_recordedAccount_inputDate}：</td>
            <td class="aux_intable_require"><table border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td ><input name="inputDate" type="text" class="required validate-date-yyyy-MM-dd validate-ajax" replaceId="dataValue"
                              validateUrl="${ctx}/common_sysrefcodeAction.do?method=compareCurrentDate&dateFormat=yyyy-MM-dd&compareType=smallEqualsCurrentDate" validateMessage="${key.charge_recordedAccount_tip}" value="" size="16" maxlength="10" afterInsert="consumeDateAfter"></td>
                <td width="4">&nbsp;</td>
                <td ><img src="${ctx}/images/ico_clock.gif" width="20" height="20" id="imgConsumeDate"><span id="consumeDateAfter"></span></td>
              </tr>
            </table></td>
          </tr>
           
          <tr>
            <td class="aux_intable_td1"> 截止缴费日期：</td>
            <c:if test="${isVirtual == '1'}">
            	<td class="aux_intable_td2"><div id="firstPayDate"></div></td>
             </c:if>
             <c:if test="${isVirtual == '0'}">
            	<td class="aux_intable_td2">${firstPayDate}</td>
             </c:if>
          </tr>
          <tr>
            <td class="aux_intable_td1"> 优惠期截止缴费日期：</td>
             <c:if test="${isVirtual == '1'}">
           	 <td class="aux_intable_td2"><div id="lastPayDate"></div></td>
             </c:if>
             <c:if test="${isVirtual == '0'}">
            	<td class="aux_intable_td2">${lastPayDate}</td>
             </c:if>
          </tr>
         
        </table>
        </form>
        </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td align="left" class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td>
        <!--
        <table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_41"></td>
              <td class="buttonOffMiddle" id="btn1_42" onClick="setCloseFlag(true);ajaxSubmit('transForm');" onMouseOver="btn_change_over(4)" onMouseOut="btn_change_out(4)" onblur="btn_change(4)"><img src="${ctx}/images/ico_saveandnewfile.gif" alt="" width="14" height="14" border="0" align="absbottom">&nbsp;保存并新增</td>
              <td class="buttonOffRight" id="btn1_43"></td>
            </tr>
        </table> --></td>
        <td class="btn_between_space">&nbsp;</td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onClick="setCloseFlag(false);ajaxSubmit('transForm');" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onBlur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom">${key.save}</td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onClick="windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onBlur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom">${key.close}</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
<script type="text/javascript">
              Calendar.setup(
              {
	              inputField : "inputDate", // ID of the input field
	              ifFormat : "%Y-%m-%d", // the date format
	              button : "imgConsumeDate", // ID of the button
	              align          :    "Tl",           // alignment (defaults to "Bl")
			      singleClick    :    true
              }
              );

</script>
</body>
</html>